#include <python2.7/Python.h>
#include <stdio.h>
int main() 
{ 
    Py_Initialize(); 
    PyRun_SimpleString("import sys");
    PyRun_SimpleString("sys.path.append('./')");

    PyObject *pModule = PyImport_ImportModule("hello"); 
    for(int i = 10; i < 10000; ++i)
    {
        PyObject *pFunc = PyObject_GetAttrString(pModule, "hello"); 
        PyEval_CallObject(pFunc, NULL); 

        pFunc = PyObject_GetAttrString(pModule, "add"); 
        PyObject *pArg = Py_BuildValue("(i, i)", 1, 2);

        PyObject *retVal = PyEval_CallObject(pFunc, pArg);
        int a = 0; int b = 0;
        if(retVal)
        {
            PyArg_ParseTuple(retVal, "i|i", &a, &b);
            printf("return value: %d, %d\n", a, b);
        }


        pFunc = PyObject_GetAttrString(pModule, "sub"); 
        pArg = Py_BuildValue("(i, i)", 1, 10);

        retVal = PyEval_CallObject(pFunc, pArg);
        long retInt = PyInt_AsLong(retVal);
        printf("return value of 1 - 10: %d\n", retInt);
    }
    Py_Finalize(); 
    return 0; 
} 
